#include <iostream>
#include <memory>
#include "Reactor.hpp"
#include "Connection.hpp"
#include "Listener.hpp"
#include "HandlerConnection.hpp"
#include "PackageParse.hpp"
int main(int argc , char* argv[])
{
    if(argc != 2)
    {
        std::cout << "Usage: " << argv[0] << "port" << std::endl;
        return 0;
    }
    uint16_t port = std::stoi(argv[1]);
    HandlerConnection hc(PackageParse::Parse);
    std::unique_ptr<Reactor> react = std::make_unique<Reactor>();
    Listener listener(port,hc);
   
    react->AddConnection(listener.ListenSock(),EPOLLIN|EPOLLET,std::bind(&Listener::Accepter,&listener,std::placeholders::_1),nullptr,nullptr);
    react->Dispatcher();
    return 0;
}